home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 22 / Amiga Format AFCD22 (Jan 1998, Issue 106).iso / -in_the_mag- / converters / graphics / netpbm / pbmrexx / manual / magic.man < prev    next >
Text File  |  1997-11-16  |  7KB  |  199 lines

  1.  
  2.  
  3.  
  4.      MAGIC(5)              AMIGA (Public Domain)              MAGIC(5)
  5.  
  6.  
  7.  
  8.      NAME
  9.           magic - file command's magic number file
  10.  
  11.      DESCRIPTION
  12.           The file(1) command identifies the type of a file using,
  13.           among other tests, a test for whether the file begins with a
  14.           certain magic number.  The file /etc/magic specifies what
  15.           magic numbers are to be tested for, what message to print if
  16.           a particular magic number is found, and additional
  17.           information to extract from the file.
  18.  
  19.           Each line of the file specifies a test to be performed.  A
  20.           test compares the data starting at a particular offset in
  21.           the file with a 1-byte, 2-byte, or 4-byte numeric value or a
  22.           string.  If the test succeeds, a message is printed.  The
  23.           line consists of the following fields:
  24.  
  25.           offset   A number specifying the offset, in bytes, into the
  26.                    file of the data which is to be tested.
  27.  
  28.           type     The type of the data to be tested.  The possible
  29.                    values are:
  30.  
  31.                    byte     A one-byte value.
  32.  
  33.                    short    A two-byte value (on most systems) in this
  34.                             machine's native byte order.
  35.  
  36.                    long     A four-byte value (on most systems) in
  37.                             this machine's native byte order.
  38.  
  39.                    string   A string of bytes.
  40.  
  41.                    date     A four-byte value interpreted as a unix
  42.                             date.
  43.  
  44.                    beshort  A two-byte value (on most systems) in
  45.                             big-endian byte order.
  46.  
  47.                    belong   A four-byte value (on most systems) in
  48.                             big-endian byte order.
  49.  
  50.                    bedate   A four-byte value (on most systems) in
  51.                             big-endian byte order, interpreted as a
  52.                             unix date.
  53.  
  54.                    leshort  A two-byte value (on most systems) in
  55.                             little-endian byte order.
  56.  
  57.                    lelong   A four-byte value (on most systems) in
  58.                             little-endian byte order.
  59.  
  60.  
  61.  
  62.  
  63.      Page 1                                          (printed 1/23/95)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      MAGIC(5)              AMIGA (Public Domain)              MAGIC(5)
  71.  
  72.  
  73.  
  74.                    ledate   A four-byte value (on most systems) in
  75.                             little-endian byte order, interpreted as a
  76.                             unix date.
  77.  
  78.           The numeric types may optionally be followed by & and a
  79.           numeric value, to specify that the value is to be AND'ed
  80.           with the numeric value before any comparisons are done.
  81.           Prepending a u to the type indicates that ordered
  82.           comparisons should be unsigned.
  83.  
  84.           test The value to be compared with the value from the file.
  85.                If the type is numeric, this value is specified in C
  86.                form; if it is a string, it is specified as a C string
  87.                with the usual escapes permitted (e.g. \n for new-
  88.                line).
  89.  
  90.                Numeric values may be preceded by a character
  91.                indicating the operation to be performed.  It may be =,
  92.                to specify that the value from the file must equal the
  93.                specified value, <, to specify that the value from the
  94.                file must be less than the specified value, >, to
  95.                specify that the value from the file must be greater
  96.                than the specified value, &, to specify that the value
  97.                from the file must have set all of the bits that are
  98.                set in the specified value, or ^, to specify that the
  99.                value from the file must have clear any of the bits
  100.                that are set in the specified value.
  101.  
  102.                Numeric values are specified in C form; e.g.  13 is
  103.                decimal, 013 is octal, and 0x13 is hexadecimal.  to
  104.                specify that any value will match.  If the character is
  105.                omitted, it is assumed to be =.
  106.  
  107.                For string values, the byte string from the file must
  108.                match the specified byte string. The operators =, < and
  109.                > (but not &) can be applied to strings.  The length
  110.                used for matching is that of the string argument in the
  111.                magic file.  This means that a line can match any
  112.                string, and then presumably print that string, by doing
  113.                >\0 (because all strings are greater than the null
  114.                string).
  115.  
  116.           message
  117.                The message to be printed if the comparison succeeds.
  118.                If the string contains a printf(3S) format
  119.                specification, the value from the file (with any
  120.                specified masking performed) is printed using the
  121.                message as the format string.
  122.  
  123.           Some file formats contain additional information which is to
  124.           be printed along with the file type.  A line which begins
  125.           with the character > indicates additional tests and messages
  126.  
  127.  
  128.  
  129.      Page 2                                          (printed 1/23/95)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      MAGIC(5)              AMIGA (Public Domain)              MAGIC(5)
  137.  
  138.  
  139.  
  140.           to be printed.  The number of > on the line indicates the
  141.           level of the test; a line with no > at the beginning is
  142.           considered to be at level 0.  Each line at level n+1 is
  143.           under the control of the line at level n most closely
  144.           preceding it in the magic file.  If the test on a line at
  145.           level n succeeds, the tests specified in all the subsequent
  146.           lines at level n+1 are performed, and the messages printed
  147.           if the tests succeed.  The next line at level n terminates
  148.           this.  If the first character following the last > is a (
  149.           then the string after the parenthesis is interpreted as an
  150.           indirect offset.  That means that the number after the
  151.           parenthesis is used as a offset in the file. The value at
  152.           that offset is read, and is used again as an offset in the
  153.           file. Indirect offsets are of the form:  ((x[.[bsl]][+-
  154.           ][y]).  The value of x is used as an offset in the file. A
  155.           byte, short or long is read at that offset depending on the
  156.           [bsl] type specifier. To that number the value of y is added
  157.           and the result is used as an offset in the file. The default
  158.           type if one is not specified is long.
  159.  
  160.      BUGS
  161.           The formats long, belong, lelong, short, beshort, leshort,
  162.           date, bedate, and ledate are system-dependant; perhaps they
  163.           should be specified as a number of bytes (2B, 4B, etc),
  164.           since the files being recognized typically come from a
  165.           system on which the lengths are invariant.
  166.  
  167.           There is (currently) no support for specified-endian data to
  168.           be used in indirect offsets.
  169.  
  170.      SEE ALSO
  171.           file(1) - the command that reads this file.
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.      Page 3                                          (printed 1/23/95)
  196.  
  197.  
  198.  
  199.